package com.hsnn.medstgmini.pro.base.controller;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.base.std.model.StdHealthbureau;
import com.hsnn.medstgmini.pro.base.service.WsjAnaDruginfoManager;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.util.DbUtil;
import com.hsnn.medstgmini.util.Pagination;

/**
 * @category 统计与查询(卫生局)
 * @author wangbing
 * @date 2015年12月1日10:16:59
 */
@Controller
@RequestMapping("/wsjAnaDruginfo")
public class WsjAnaDruginfoController {

	private static final Logger log = Logger.getLogger(WsjAnaDruginfoController.class);
	@Autowired
	private  WsjAnaDruginfoManager wsjAnaDruginfoManager;
	
	@Autowired
	private HttpServletRequest request;

	@Autowired
	private HttpSession session;
	

	/**
	 * @category 按医院统计(月)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjMonthAnaByHosp")
	public String toWsjMonthAnaByHosp() {
		return "/pro/base/anaDruginfo/wsjMonthAnaByHosp";
	}
	@ResponseBody
	@RequestMapping("/getWsjMonthAnaByHosp")
	public Pagination getWsjMonthAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjMonthAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按医院统计(年)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjYearAnaByHosp")
	public String toWsjYearAnaByHosp() {
		return "/pro/base/anaDruginfo/wsjYearAnaByHosp";
	}
	@ResponseBody
	@RequestMapping("/getWsjYearAnaByHosp")
	public Pagination getWsjYearAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjYearAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按医院统计(季度)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjSeaAnaByHosp")
	public String toWsjSeaAnaByHosp() {
		return "/pro/base/anaDruginfo/wsjSeaAnaByHosp";
	}
	@ResponseBody
	@RequestMapping("/getWsjSeaAnaByHosp")
	public Pagination getWsjSeaAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjSeaAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按医院统计(日)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjAnaByHosp")
	public String toWsjAnaByHosp() {
		return "/pro/base/anaDruginfo/wsjAnaByHosp";
	}
	@ResponseBody
	@RequestMapping("/getWsjAnaByHosp")
	public Pagination getWsjAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/*----------------------------------------------按企业统计------------------------------------------------*/
	
	/**
	 * @category 按企业统计(月)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjMonthAnaByComp")
	public String toWsjMonthAnaByComp() {
		return "/pro/base/anaDruginfo/wsjMonthAnaByComp";
	}
	@ResponseBody
	@RequestMapping("/getWsjMonthAnaByComp")
	public Pagination getWsjMonthAnaByComp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjMonthAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按企业统计(年)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjYearAnaByComp")
	public String toWsjYearAnaByComp() {
		return "/pro/base/anaDruginfo/wsjYearAnaByComp";
	}
	@ResponseBody
	@RequestMapping("/getWsjYearAnaByComp")
	public Pagination getWsjYearAnaByComp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjYearAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按企业统计(季度)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjSeaAnaByComp")
	public String toWsjSeaAnaByComp() {
		return "/pro/base/anaDruginfo/wsjSeaAnaByComp";
	}
	@ResponseBody
	@RequestMapping("/getWsjSeaAnaByComp")
	public Pagination getWsjSeaAnaByComp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjSeaAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按企业统计(日)
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toWsjAnaByComp")
	public String toWsjAnaByComp() {
		return "/pro/base/anaDruginfo/wsjAnaByComp";
	}
	@ResponseBody
	@RequestMapping("/getWsjAnaByComp")
	public Pagination getWsjAnaByComp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) session.getAttribute(Constants.USERINFO);
			StdHealthbureau sh = user.getInfo();
			page.getConditions().put("areaId", sh.getArea().getAreaid());
			DbUtil.jsonToMap(request, page);
			
			page = wsjAnaDruginfoManager.getWsjAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
}
